<template>
	<view class="coach">
		<view class="header-bg">
			<custom-navbar :statusBarHeight="statusBarHeight" :navBarHeight="navBarHeight" :windowWidth="windowWidth"
				:color="color" :backgroundColor="backgroundColor" :iconShow="false">
				<image :src="$IMG_URL('/static/home/scan.png')" mode="aspectFill" class="scan" @tap.stop="scan"></image>
			</custom-navbar>
			<!-- 需要添加占位符高度  状态栏高度+导航栏高度（否则下面tab会塌陷）-->
			<view :style="{height: statusBarHeight+navBarHeight+'px'}"></view>
		</view>
		<view class="comlum_box">
			<subscriber :userQuery="query">
				<view class="cutbtn" @click="changeMy">
					<image :src="$IMG_URL('/static/newVersion/cut.png')" mode="" class="cut"></image>
					回到我的
				</view>
			</subscriber>
			<view class="card" style="background: #ffffff;">
				<view class="bottom">
					<view class="comlum_Y border_right1" @click="openBalance = !openBalance">
						<view class="title3">
							今日业绩(元)
							<image :src="openBalance?$IMG_URL('/static/user/eye.png'):$IMG_URL('/static/user/eyeoff.png')"
								mode="" class="icon"></image>
						</view>
						<view class="money2" v-if="openBalance">
							<text class="size3">{{ $FORMATCOST(query.today_cost).integer }}</text>
							<text class="size2">{{ $FORMATCOST(query.today_cost).decimal  }}</text>
						</view>
						<view class="Hidden_amount2 size3" v-else>
							****
						</view>
					</view>
					<view class="comlum_Y pl">
						<view class="title3">
							本月业绩(元)
						</view>
						<view class="money2" v-if="openBalance">
							<text class="size3">{{ $FORMATCOST(query.month_cost).integer}}</text>
							<text class="size2">{{ $FORMATCOST(query.month_cost).decimal}}</text>
						</view>
						<view class="Hidden_amount2 size3" v-else>
							****
						</view>
					</view>
				</view>
			</view>
			<view class="footbox">
				<!-- <view class="row" @click="$ROUTELINK('/pageC/rank')">
					<image src="/static/stock/Ranking.png" mode="" class="tag7"></image>
					<view class="size">
						排名
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view> -->
				<view class="row" @click="$ROUTELINK('/pageC/coach/InStoreMember2')">
					<image :src="$IMG_URL('/static/user/managertag4.png')" mode="" class="tag2"></image>
					<view class="size">
						到店会员
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
				<view class="row" @click="$ROUTELINK('/pageC/coach/student2')">
					<image :src="$IMG_URL('/static/user/managertag1.png')" mode="" class="tag1"></image>
					<view class="size">
						我的学员
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
				<view class="row" @click="$ROUTELINK('/pageC/coach/classList')">
					<image :src="$IMG_URL('/static/test/class1.png')"  mode="" class="tag3"></image>
					<view class="size">
						学员课程列表
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
				<view class="row" @click="$ROUTELINK('/pageC/coach/goClasshistory')">
					<image :src="$IMG_URL('/static/test/goclass.png')" mode="" class="tag3"></image>
					<view class="size">
						学员上课记录
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
				<view class="row" @click="$ROUTELINK('/pageC/coach/qrcode')">
					<image :src="$IMG_URL('/static/user/QRcode.png?time=' + 1)" mode="" class="tag2"></image>
					<view class="size">
						收款码订单管理
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
				<!-- routeMemberPhysical -->
				<view class="row"  @click="$EXPLOIT()">
					<image :src="$IMG_URL('/static/test/tice1.png')" mode="" class="tag4"></image>
					<view class="size">
						学员体测记录
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
				<view class="row" @click="$ROUTELINK('/pageC/coach/CourseSalesRecord')">
					<image :src="$IMG_URL('/static/user/managertag6.png')" mode="" class="tag6" ></image>
					<view class="size">
						业绩记录
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
				<view class="row" @click="$ROUTELINK('/pageC/coach/my_courses')">
					<image :src="$IMG_URL('/static/user/managertag5.png')" mode="" class="tag2"></image>
					<view class="size">
						我的课程
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
				<view class="row" @click="$ROUTELINK('/pageC/coach/setting')">
					<image :src="$IMG_URL('/static/user/usertag5.png')" mode="" class="tag5"></image>
					<view class="size">
						设置
					</view>
					<u-icon name="arrow-right" color="#CCCCCC" size="14"></u-icon>
				</view>
			</view>
			<view class="empty">
				
			</view>
		</view>
	</view>
</template>

<script>
	import subscriber from './components/subscriber.vue';
	import CustomNavbar from '@/components/navbar/navbar.vue';
	import{
		userCoachmain
	} from '@/api/coach.js'
	import {
		analysisQrCode
	} from '@/api/home.js'
	export default {
		components: {
			subscriber,
			CustomNavbar
		},
		data() {
			return {
				// 自定义导航栏
				color: '#ffffff',
				backgroundColor: 'transparent',
				pageTitle: '',
				statusBarHeight: 20,
				navBarHeight: 45,
				windowWidth: 375,
				openBalance: false,
				query:{}
			}
		},
		mounted() {
			this.getUserCoachmain()
		},
		methods: {
			routeMemberPhysical(){
				uni.navigateTo({
					url:'/pageC/coach/physicalHistory'
				})
			},
			getanalysisQrCode(ee){
				analysisQrCode(ee).then(({data:res})=>{
					console.log('res', res);
					if(res.code == 1){
						uni.navigateTo({
							url:'/pageB/receive/index?query=' + JSON.stringify(res.data)
						})
					}
				})
			},
			scan(){
				let t = this
				uni.scanCode({
					success: function(saoma) {
						console.log('saoma', saoma);
						if (saoma.errMsg === 'scanCode:ok') {
							let queryString = saoma.path
							let parts = queryString.split('scene=');
							if (parts.length > 1) {
							    let sceneValue = parts[1]; // 这将包含 '8ebd3f8bdb1788d2bd5d51cab45b0c9vue'
							    console.log(sceneValue, 'sceneValue');
								t.getanalysisQrCode({
									scene:sceneValue
								})
							}
							// const obj = JSON.parse(saoma.result)
			
						} else {
							uni.showToast({
								title: '扫码失败',
								icon: 'none'
							})
						}
				
					}
				});
			},
			changeMy() {
				this.$emit(('changMy'))
			},
			getUserCoachmain(){
				userCoachmain().then(({data:res})=>{
					console.log('res', res);
					if(res.code == 1){
						this.query = res.data
					}else{
						let that = this
						uni.showModal({
						  title: '温馨提示',
						  content: res.msg,
						  showCancel: false,
						  confirmText: '确认',
						  confirmColor:'#73F0EA',
						  success: function (res) {
						    if (res.confirm) {
								that.$emit(('changMy'))
						    } else if (res.cancel) {
						      // 用户点击了不同意按钮，可以执行退出应用或阻止后续操作的逻辑
						      console.log('用户未同意协议');
						    }
						  }
						});
					}
				})
			}
		},
		created() {
			// 获取手机系统信息
			const info = uni.getSystemInfoSync()
			// 设置状态栏高度（H5顶部无状态栏小程序有状态栏需要撑起高度）
			this.statusBarHeight = info.statusBarHeight
			this.windowWidth = info.windowWidth
			// 除了h5 app mp-alipay的情况下执行
			// #ifndef H5 || APP-PLUS || MP-ALIPAY
			// 获取胶囊的位置
			const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			console.log(menuButtonInfo);
			// (胶囊底部高度 - 状态栏的高度) + (胶囊顶部高度 - 状态栏内的高度) = 导航栏的高度
			this.navBarHeight = (menuButtonInfo.bottom - info.statusBarHeight) + (menuButtonInfo.top - info
				.statusBarHeight)
			this.windowWidth = menuButtonInfo.left
			// #endif
		},
	}
</script>

<style lang="scss">
	page {
		background: #e9e9e9;
	}

	.scan {
		width: 40rpx;
		height: 40rpx;
		margin-left: 30rpx;
	}

	.cutbtn {
		width: 90px;
		height: 30px;
		background: rgba(255, 255, 255, 0.5);
		border-radius: 8px;
		font-size: 14px;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		text-align: left;
		color: #000000;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;

		.cut {
			width: 14px;
			height: 12px;
			margin-right: 5rpx;
		}
	}

	.coach {
		display: flex;
		flex-direction: column;
		align-items: center;

		.header-bg {
			width: 750rpx;
			height: 550rpx;
			background: linear-gradient(180deg, #73F0EA, rgba(255, 255, 255, 0.00));
			display: flex;
			flex-direction: column;
		}

		.comlum_box {
			margin-top: -360rpx;
			width: 750rpx;
			display: flex;
			flex-direction: column;
			align-items: center;

			.Hidden_amount {
				font-family: DIN, DIN-Bold;
				font-weight: 700;
				text-align: left;
				color: #ffffff;
			}
			.Hidden_amount2 {
				font-family: DIN, DIN-Bold;
				font-weight: 700;
				text-align: left;
				color: #000000;
			}
			.pl{
				padding-left: 40rpx;
			}
			.money1 {
				display: flex;
				flex-direction: row;
				align-items: baseline;
				font-family: DIN, DIN-Bold;
				font-weight: 700;
				text-align: left;
				color: #ffffff;

			}
			.money2 {
				display: flex;
				flex-direction: row;
				align-items: baseline;
				font-family: DIN, DIN-Bold;
				font-weight: 700;
				text-align: left;
				color: #000000;
			
			}

			.size1 {
				font-size: 48rpx;
			}

			.size2 {
				font-size: 24rpx;
			}
			.size3{
				font-size: 36rpx;
			}
			.card {
				width: 686rpx;
				border-radius: 32rpx;
				padding: 40rpx;
				margin-bottom: 20rpx;
				.balance {
					display: flex;
					flex-direction: column;
					padding-bottom: 30rpx;
					border-bottom: 1rpx solid rgba(255, 255, 255, 0.2);

					.title {
						display: flex;
						flex-direction: row;
						align-items: center;
						margin-bottom: 12rpx;

						.size {
							opacity: 0.8;
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC-Bold;
							font-weight: 700;
							text-align: left;
							color: #ffffff;
						}

						.icon {
							width: 36rpx;
							height: 22rpx;
							margin-left: 10rpx;
						}
					}

				}
			}

			.bottom {
				display: flex;
				flex-direction: row;
				align-items: center;
				width: 100%;
				padding-top: 34rpx;
				.icon {
					width: 36rpx;
					height: 22rpx;
					margin-left: 10rpx;
				}
				.border_right {
					border-right: 1rpx solid rgba(255, 255, 255, 0.2);
				}
				
				.border_right1{
					border-right: 1rpx solid #e9e9e9;
				}
				.comlum_Y {
					display: flex;
					flex-direction: column;
					flex: 0.5;

					.title2 {
						opacity: 0.8;
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Bold;
						font-weight: 700;
						text-align: left;
						color: #ffffff;
						margin-bottom: 8rpx;
					}
					.title3{
						display: flex;
						flex-direction: row;
						align-items: center;
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC-Regular;
						font-weight: 400;
						text-align: left;
						color: #666666;
						margin-bottom: 8rpx;
					}
				}
			}
		}
		.footbox {
			margin-top: 20rpx;
			width: 686rpx;
			background: #ffffff;
			border-radius: 32rpx;
			padding: 0 32rpx;
		
			.row {
				height: 102rpx;
				width: 100%;
				display: flex;
				flex-direction: row;
				align-items: center;
				padding: 0 14.5rpx;
				border-bottom: 2rpx solid #f8f8f8;
		
				.tag1 {
					width: 32rpx;
					height: 32rpx;
				}
		
				.tag2{
					width: 32rpx;
					height: 36rpx;
				}
				.tag3{
					width: 32rpx;
					height: 38rpx;
				}
				.tag4{
					width: 32rpx;
					height: 38rpx;
				}
				.tag5{
					width: 32rpx;
					height: 30rpx;
				}
				.tag6{
					width: 32rpx;
					height: 34rpx;
				}
				.tag7{
					width: 38rpx;
					height: 38rpx;
				}
				.size {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-Bold;
					font-weight: 700;
					text-align: left;
					color: #333333;
					margin-left: 30rpx;
					flex: 1;
				}
			}
		}
		.empty{
			width: 100%;
			height: 20rpx;
		}
	}
</style>